package com.SinaMicrobloggingApi.Core.Request;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import com.SinaMicrobloggingApi.Core.OauthConstants;
import com.SinaMicrobloggingApi.Core.Response.IResponse;

public class SendMessageRequest extends RequestBase {
	private static final String SEND_MESSAGE = "SendMessage";
	private static final String TEXT = "text";
	private static final String ID = "id";
	private String text = "";
	private int toUserId;

	public SendMessageRequest(IResponse response, int touserId, String text) {
		super(response);
		// TODO Auto-generated constructor stub
		this.text = handingString(text);
		this.toUserId = touserId;
	}

	@Override
	protected String getRequestName() {
		// TODO Auto-generated method stub
		return SEND_MESSAGE;
	}

	protected HttpMethodEnum getHttpMethod() {
		return HttpMethodEnum.POST;
	}

	protected String getRequestParamenters() {

		BasicNameValuePair oauth_token = new BasicNameValuePair(
				OauthConstants.OAUTH_TOKEN_KEY, getOauthToken());
		BasicNameValuePair oauth_status = new BasicNameValuePair(TEXT, text);
		BasicNameValuePair oauth_source = new BasicNameValuePair(
				RequestBase.SOURCE, super.getConsumerKey());
		BasicNameValuePair oauth_to_userId = new BasicNameValuePair(ID, String
				.valueOf(toUserId));
		oauthParamenterModels.add(oauth_token);
		oauthParamenterModels.add(oauth_status);
		oauthParamenterModels.add(oauth_source);
		oauthParamenterModels.add(oauth_to_userId);

		return super.getRequestParamenters();
	}

}
